
package com.jeeplus.modules.work.FCJJD.service;

import java.util.ArrayList;
import java.util.List;

import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.database.datasource.annotation.DS;
import com.jeeplus.modules.work.FCJJD.entity.StreetWindowBean;
import com.jeeplus.modules.work.FCJJD.mapper.StreetWindowMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



@DS("fcjjd")
@Service
@Transactional(readOnly = true)
public class StreetWindowService {
	@Autowired
	private StreetWindowMapper streetWindowMapper;

	public AjaxJson findListDate(){
		List<StreetWindowBean> listDate = streetWindowMapper.findListDate();
		List<StreetWindowBean> winListA = new ArrayList<StreetWindowBean>();
		List<StreetWindowBean> winListB = new ArrayList<StreetWindowBean>();
		List<StreetWindowBean> winListC = new ArrayList<StreetWindowBean>();
		int totalA = 0;//办理中
		int totalB = 0;//空闲中
		int totalC = 0;//未登录
		for (int i = 0; i < listDate.size(); i++) {
			StreetWindowBean streetWindowBean = listDate.get(i);
			if ("".equals(streetWindowBean.getUserName()) || null == streetWindowBean.getUserName()){
				totalC++;
				streetWindowBean.setStatus("N");
				streetWindowBean.setStatusName("未登录");
				streetWindowBean.setNumberNum("0");
				winListC.add(streetWindowBean);
			}else {
				System.out.println(streetWindowBean.getWinName()+"===============================================");
				String winId = streetWindowBean.getWinId();
				String doNumberByWinId = streetWindowMapper.findDoNumberByWinId(winId);
				if("".equals(doNumberByWinId) || null == doNumberByWinId){
					totalB++;
					streetWindowBean.setStatus("L");
					streetWindowBean.setStatusName("空闲中");
					streetWindowBean.setNumberNum("0");
					winListB.add(streetWindowBean);
				}else {
					totalA++;
					streetWindowBean.setStatus("W");
					streetWindowBean.setStatusName("办理中");
					streetWindowBean.setDoNumber(doNumberByWinId);
					winListA.add(streetWindowBean);
				}



			}



		}

		return AjaxJson.success().put("dataA",winListA).put("dataB",winListB).put("dataC",winListC).put("totalA",totalA).put("totalB",totalB).put("totalC",totalC);
	};






}
